package cn.wolfcode.car.business.service.impl;


import cn.wolfcode.car.business.domain.Appointment;
import cn.wolfcode.car.business.domain.Statement;
import cn.wolfcode.car.business.mapper.StatementItemMapper;
import cn.wolfcode.car.business.mapper.StatementMapper;
import cn.wolfcode.car.business.query.StatementQuery;
import cn.wolfcode.car.business.service.IStatementService;
import cn.wolfcode.car.common.base.page.TablePageInfo;
import cn.wolfcode.car.common.util.Convert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
@Transactional
public class StatementServiceImpl extends ServiceImpl<StatementMapper,Statement> implements IStatementService {

    @Autowired
    private StatementMapper statementMapper;

    @Autowired
    private StatementItemMapper statementItemMapper;

    @Override
    public TablePageInfo<Statement> query(StatementQuery qo) {
        PageHelper.startPage(qo.getPageNum(), qo.getPageSize());
        QueryWrapper<Statement> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.hasText(qo.getCustomerName()),"customer_name",qo.getCustomerName());
        wrapper.like(StringUtils.hasText(qo.getCustomerPhone()),"customer_phone",qo.getCustomerPhone());
        wrapper.like(StringUtils.hasText(qo.getLicensePlate()),"license_plate",qo.getLicensePlate());
        return new TablePageInfo<Statement>(statementMapper.selectList(wrapper));
    }
}
